<template>
	<view class="content">
		<tabbar class="tabbar" :dataArray="dataArray" :checkedIndex="checkedIndex"
			@handleIndexChange="handleIndexChange"></tabbar>
		<scroll-view scroll-y="true" class="list">
			<notificationListItem v-for="(item,index) in list" @goTo="goTo" :id="item.id" :img="item.img"
				:title="item.title" :dateString="item.createDate" content="">
			</notificationListItem>
			<!-- <notificationListItem @goTo="goTo" :title="'展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题'"
				:dateString="'2021/7/20'" :content="'通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容'">
			</notificationListItem>
			<notificationListItem :title="'展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题'" :dateString="'2021/7/20'"
				:content="'通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容'"></notificationListItem>
			<notificationListItem :title="'展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题'" :dateString="'2021/7/20'"
				:content="'通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容'"></notificationListItem>
			<notificationListItem :title="'展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题展览标题'" :dateString="'2021/7/20'"
				:content="'通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容通知内容'"></notificationListItem> -->
		</scroll-view>
	</view>
</template>

<script>
	import {
		doPostForm
	} from '../../js_sdk/request-helper.js'
	import {
		dateToString
	} from '../../js_sdk/date-parse/date-parser.js'
	import tabbar from '../customer/tabbar.vue'
	import notificationListItem from '../customer/notificationListItem.vue'
	export default {
		components: {
			tabbar,
			notificationListItem
		},
		data() {
			return {
				img: "../../static/v2_qw2hcs.jpg",
				checkedIndex: 0,
				dataArray: ["通知公告", "新闻动态", '公众动态'],

				list: []
			}
		},
		onLoad() {
			this.getList(this.checkedIndex + 1)
		},
		methods: {
			handleIndexChange(index) {
				this.checkedIndex = index
				this.getList(index + 1)
			},
			goTo(id) {
				uni.navigateTo({
					url: "./notificationInfo?id=" + id
				})
			},
			getList(typeCode) {
				doPostForm('/blade-museum/ntf/list', {
					pages: 0,
					size: 8,
					typeCode: typeCode,
					auditState: true,
					museumId: uni.getStorageSync('museumId')
				}, (res) => {
					let list = []
					for (let item of res.records) {
						item.createDate = dateToString(new Date(item.createTime.replace(/-/g, '/')), 'yyyy/mm/dd')
						list.push(item)
					}
					this.list = list
				}, (err) => {})
			},
		}
	}
</script>

<style>
	.content {
		position: fixed;
		width: 100%;
		height: calc(100% - 88rpx);
		background: #eee;
	}

	.tabbar {
		background: #fff;
	}

	.list {
		height: calc(100% - 88rpx);
	}

	.content image {
		margin: 20rpx;
		width: calc(100% - 40rpx);
		height: auto;
	}
</style>
